package com.alex.j2se;

import java.util.ArrayList;
import java.util.List;
import java.util.StringJoiner;
import java.util.stream.Collectors;

/**
 * @description:
 * @author: gaojun
 * @date: 2021/3/16
 */
public class StringJoinerTest {
    public static void main(String[] args) {
        List<String> stringList = new ArrayList<>();
        stringList.add("1");
        stringList.add("2");
        stringList.add("3");
//        stringList.add("4");

        System.out.println(stringList.stream().filter(s -> !"3".equals(s)).collect(Collectors.joining(",")));

        StringJoiner stringJoiner = new StringJoiner(",");
        stringList.stream().filter(s -> !"3".equals(s)).collect(Collectors.toList()).forEach(stringJoiner::add);
        System.out.println(stringJoiner.toString());
    }
}
